﻿using System;
using System.Collections;
using UnityEngine;

namespace UniRx.Examples
{
	// Token: 0x020001EA RID: 490
	public class Sample06_ConvertToCoroutine : MonoBehaviour
	{
		// Token: 0x06000A40 RID: 2624 RVA: 0x0003703A File Offset: 0x0003543A
		private void Start()
		{
			base.StartCoroutine(this.ComplexCoroutineTest());
		}

		// Token: 0x06000A41 RID: 2625 RVA: 0x0003704C File Offset: 0x0003544C
		private IEnumerator ComplexCoroutineTest()
		{
			yield return new WaitForSeconds(1f);
			int v = 0;
			yield return Observable.Range(1, 10).StartAsCoroutine(delegate(int x)
			{
				v = x;
			}, default(CancellationToken));
			Debug.Log(v);
			yield return new WaitForSeconds(3f);
			yield return Observable.Return<int>(100).StartAsCoroutine(delegate(int x)
			{
				v = x;
			}, default(CancellationToken));
			Debug.Log(v);
			yield break;
		}

		// Token: 0x06000A42 RID: 2626 RVA: 0x00037060 File Offset: 0x00035460
		private IEnumerator TestNewCustomYieldInstruction()
		{
			yield return Observable.Timer(TimeSpan.FromSeconds(1.0)).ToYieldInstruction<long>();
			yield return Observable.Timer(TimeSpan.FromSeconds(1.0), Scheduler.MainThreadIgnoreTimeScale).ToYieldInstruction<long>();
			ObservableYieldInstruction<string> o = ObservableWWW.Get("http://unity3d.com/", null, null).ToYieldInstruction(false);
			yield return o;
			if (o.HasError)
			{
				Debug.Log(o.Error.ToString());
			}
			if (o.HasResult)
			{
				Debug.Log(o.Result);
			}
			yield return this.ObserveEveryValueChanged((Sample06_ConvertToCoroutine x) => x.transform, FrameCountType.Update, false).FirstOrDefault((Transform x) => x.position.y >= 100f).ToYieldInstruction<Transform>();
			yield break;
		}
	}
}
